<?php 
if (! defined('BASEPATH')) {
	exit('Access Denied');
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>关键词列表</title>
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>/static/css/admin/base.css">
<link rel="stylesheet" href="<?php echo base_url();?>/static/js/editor/themes/default/default.css" />

<script src="<?php echo base_url();?>/static/js/jquery.js" language="javascript"></script>

<script type="text/javascript">


</script>
<style>
#list ul li{
	float:left;
	width:160px;
	height:30px;
	line-height:30px;
	border:solid 1px #FAFAF1;
	padding:3px;
	margin:3px;
	text-align:center;
	display:inline-block;
	cursor:pointer;
	background:#E7E7E7
	
}
#list ul li a:hover{
	
}
#list{
	word-break: break-all;
    word-wrap: break-word;
	width:100%
}
</style>
<script>
var num = 1 ;
function choose(o){
	if(num>4){
		alert('最多选择4个');
		return false ;
	}
	
	
	$("#has_choose").append("<input type='checkbox' value="+o.innerHTML+" checked onclick=\"del("+num+",this)\" id='checkbox_"+num+"' class=\"checkbox\"><span id=\"span_"+num+"\">"+o.innerHTML+"</span>");
	num++ ;
}
function last_(){
	var str = '' ;
	$(".checkbox").each(function(i){
		
		str+=$(this).val()+",";
	});
	if(str != ''){
		str = str.substring(0,str.length-1);
	}
	parent.$("#keyword").val(str);
	parent.$("#windownbg").remove();
	parent.$("#windown-box").fadeOut("slow",function(){$(this).remove();});
}
function del(id,o){
	
	if(!o.checked){
		//删除
		$("#checkbox_"+id).remove();
		$("#span_"+id).remove();
		num = num-1 ;
	}
}
</script>
</head>
<body leftmargin="8" topmargin="8">
<div>
	已经选择:<span id="has_choose"></span>
</div>
<div id="list">

	<ul>
		<?php 
			if($list){
				foreach($list as $k=>$v){
			
		?>
		<li><a href="javascript:void(0)" onclick="choose(this)"><?php echo $v['tagname'];?></a></li>
		
		<?php 
			}
		}else{
			echo "<li>暂无关键词，请去生成关键词缓存<li>";
		}	
		?>
	</ul>
</div>
<div style="clear:both">
<input type="button" value="确&nbsp;&nbsp;定" style="width:60px; height:30px" onclick="last_()">
</div>
</body>
</html>